var orderId = getQuery("orderId")
window.onload=function () {
    initManagerOrder(orderId)

}

function initManagerOrder(orderId){
    axios.get("/order/getOrder",{
        params:{
            orderId
        }
    }).then(resp =>{
        var info = resp.data;
        console.log(info)
        $('mOrderId').innerHTML = info.id
        $('mAccept').innerHTML = info.name
        $('mAddress').innerHTML = info.address
        $('mPhone').innerHTML = info.phone
        $('mDate').innerHTML = info.date
        $('mTotal').innerHTML = info.money
        $('mStatus').innerHTML = info.status
        var str = ""

        info.infoBeans.forEach(n =>{
            console.log(n)
            str += `<tr><td>${n.product.id}</td><td>${n.product.name}</td><td>${n.product.price}</td><td>${n.num}</td></tr>`
        })

        $('mInfo').innerHTML = str
        if (info.status == "未发货"){
            $('manageGroup').innerHTML += `    <input type="button" value="发货" id="send" onclick="send(orderId)">`
        }
    })
}

function send(orderId) {
    axios.get("/order/manager/sendOrder", {
        params: {
            orderId
        }
    }).then(resp =>{
        if (resp.data == "ok"){
            location.href = "/manager/selectOrder.html?orderId="+orderId
        }
    })
}

function managerBack(){
    location.href = "/manager/selectOrder.html?orderId="+orderId
}